home *** CD-ROM | disk | FTP | other *** search
- program junior_object;
-
- {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
- { Program to illustrate the correct use of Virtual Methods, with unit }
- { }
- { JUNIOROB.PAS -> JUNIOROB.EXE R. Shaw 26.4.91 31.5.93 }
- {_____________________________________________________________________}
-
- uses Crt, staffobj;
-
- type
-
- junior = object( staff )
- procedure script1; virtual; {virtual procedures which }
- procedure script2; virtual; {override inherited procedures}
- end;
-
- procedure junior.script1;
- begin
- writeln;
- writeln( '< later >');
- writeln;
- writeln( Name, ': I do not know the letter to send for an overdraft.');
- writeln;
- end;
-
- procedure junior.script2;
- begin
- writeln( Name, ': Thank you. ');
- writeln;
- writeln( '< later still >' );
- writeln;
- writeln( Name, ': As you requested, I sent the letter headed ',LetterName,'.');
- end;
-
- {Main}
-
- var
- Young : junior;
- Old : staff;
-
- begin
- clrscr;
-
- Young.Init( 'NEWMAN' );
- Old.Init( 'SENIOR' );
-
- Old.action1;
- Young.action1;
- Old.action2;
- Young.action2;
-
- gotoXY(10,24);
- write('Press any key to conclude: ');
- repeat until keypressed;
- clrscr;
- end.
-
- { end of listing }
-